package org.jupiter.blog.common.enums;

/**
 * Permission type enum 权限类型（menu=菜单, button=按钮, api=接口）
 */
public enum PermissionType {

	MENU("menu", "Menu"),
	BUTTON("button", "Button"),
	API("api", "API");

	private final String code;

	private final String label;

	PermissionType(String code, String label) {
		this.code = code;
		this.label = label;
	}

	public String getCode() {
		return code;
	}

	public String getLabel() {
		return label;
	}

	public static PermissionType fromCode(String code) {
		if (code == null){
			return null;
		}
		for (PermissionType type : values()){
			if (type.code.equalsIgnoreCase(code)){
				return type;
			}
		}
		return null;
	}
}


